﻿using System;
using System.Data.Entity;
using PortalWeb.Core.Entity;
using PortalWeb.Dao.Mapping;

namespace PortalWeb.Dao.Base
{
    public partial class ApplicationIdentityDbContext : DbContext, IDisposable
    {
        public ApplicationIdentityDbContext()
            : base("IdentityDbConnection")
        {
            Database.CreateIfNotExists();
        }

        public IDbSet<OperationLog> OperationLogs { get; set; }

        public IDbSet<Function> SystemFunctions { get; set; }

        public IDbSet<RoleGroup> RoleGroups { get; set; }

        public IDbSet<ConfigItem> ConfigItems { get; set; }

        public static ApplicationIdentityDbContext Create()
        {
            return new ApplicationIdentityDbContext();
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new ApplicationRoleMap());
            modelBuilder.Configurations.Add(new RoleGroupMap());
            modelBuilder.Configurations.Add(new SystemFunctionMap());
            base.OnModelCreating(modelBuilder);
        }
    }
}
